<template>
  <div class="app-container">
    <FormCom class="form-search form-inline" ref="search" :columns="queryColumns" labelWidth="3em" v-show="showSearch"/>
    <div class="flr mb8">
      <div class="flbox">
        <el-button type="primary" plain size="mini" @click="handleAdd">新增</el-button>
      </div>
      <div class="flone">
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </div>
    </div>
    <div>
      <TableCom :columns="tableColumns" :options="tableOptions" @selection-change="handleSelectionChange"
                @getList="getList"></TableCom>
    </div>
  </div>
</template>

<script>
  import indexVue from '@/config/indexVue';

  const editColumns = [
    {text: "企业类型", name: "cate", type: "select",options:"company_link"},
    {text: "企业名称", name: "name", type: "input"},
    {text: "企业地址", name: "link", type: "input"},
  ]
  const editRule = {
    cate:["required"]
  }

  export default {
    name: "CompanyLink",
    mixins:[indexVue],
    data() {
      this.actionName = "companyLink";
      this.editColumns = editColumns;
      this.editRule = editRule;
      this.queryColumns = [
        { text:"企业类型",name:"cate",type:"select",options:"company_link",onChange:this.handleQuery},
        { type:"label",searchButton:{listQuery:this.handleQuery, listReset:this.resetQuery}}
      ]
      this.tableColumns = [
        { type:"selection",fixed:true },
        {"prop":"cate","label":"企业类型","width":100,options:"company_link"},
        {"prop":"name","label":"企业名称","width":240},
        {"prop":"link","label":"企业链接","minWidth":200},
        {"prop":"createTime","label":"创建时间","width":160},
        { label:"操作",prop:"_",width:"200",align:"center",fixed:"right",options:[
            {text:"修改", props:{class:'primary'}, onClick:this.handleUpdate},
            {text:"删除", props:{class:'danger'}, onClick:this.handleDelete},
          ]
        }
      ]
      //
      return {}
    },
    mounted() {
      this.getList();
    },
    methods: {
      /** 新增按钮操作 */
      handleAdd(row) {
        this.dialogEdit({
          row,
          PATH_SAVE:`companyLink.add`,
          width:"540px",
          size:24,
          labelWidth:"6em",
          columns:this.editColumns,
          rules:this.editRule
        },()=>{
          this.getList();
        })
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.dialogEdit({
          row,
          PATH_SAVE:`companyLink.edit`,
          width:"540px",
          size:24,
          labelWidth:"6em",
          columns:this.editColumns,
          rules:this.editRule
        },()=>{
          this.getList();
        })
      },
    }
  };
</script>
